package com.zhou.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhou.api.dto.CheckOnWorkExamineDTO;
import com.zhou.api.dto.CheckOnWorkSaveDTO;
import com.zhou.api.entity.CheckOnWork;
import com.zhou.result.R;
import com.zhou.service.CheckOnWorkService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description : 考勤管理
 * @Author : zyy
 * @Date: 2024/9/11  16:48
 */
@RestController
@RequestMapping("checkOnWork")
@Api(tags = "考勤管理")
public class CheckOnWorkController {
    @Resource
    CheckOnWorkService checkOnWorkService;

    /**
     * 打卡
     * @return
     */
    @PostMapping("add")
    @Operation(summary = "上班打卡")
    public String add(@RequestBody CheckOnWorkSaveDTO checkOnWorkSaveDTO) {
        checkOnWorkService.add(checkOnWorkSaveDTO);
        return "打卡成功";
    }

    /**
     * 打卡下班
     * @param checkOnWorkSaveDTO
     * @return
     */
    @PostMapping("update")
    @Operation(summary = "下班打卡")
    public String update(@RequestBody CheckOnWorkSaveDTO checkOnWorkSaveDTO) {
        checkOnWorkService.update(checkOnWorkSaveDTO);
        return "打卡成功";
    }

    /**
     * 请假申请
     * @param checkOnWorkSaveDTO
     * @return
     */
    @PostMapping("askForLeave")
    @Operation(summary = "请假")
    public String askForLeave(@RequestBody CheckOnWorkSaveDTO checkOnWorkSaveDTO) {
        checkOnWorkService.askForLeave(checkOnWorkSaveDTO);
        return "请假成功";
    }

    /**
     * 审核
     * @param checkOnWorkExamineDTO
     * @return
     */
    @PostMapping("toExamine")
    @Operation(summary = "审核")
    public String toExamine(@RequestBody CheckOnWorkExamineDTO checkOnWorkExamineDTO) {
        checkOnWorkService.toExamine(checkOnWorkExamineDTO);
        return "审核成功";
    }
    /**
     * 待审核记录分页
     */
    @GetMapping("waitExamine")
    @Operation(summary = "待审核记录分页")
    public R<Page<CheckOnWork>> waitExamine(CheckOnWorkExamineDTO dto) {
        return R.success(checkOnWorkService.waitExamine(dto));
    }
    /**
     * 考勤记录分页
     */
    @GetMapping("getList")
    @Operation(summary = "考勤记录分页")
    public R<Page<CheckOnWork>> getList(CheckOnWorkSaveDTO dto) {
        return R.success(checkOnWorkService.getList(dto));
    }

}
